package crmdna.member;


import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

import com.google.gson.Gson;

public class UnverifiedProgramTest {

	@Test public void getUnverifiedProgramPropTest() {
		UnverifiedProgramProp uvp1 = new UnverifiedProgramProp();
		uvp1.programTypeId = 1;
		uvp1.city = "chennai";
		uvp1.country = "india";
		
		UnverifiedProgramProp uvp2 = new UnverifiedProgramProp();
		uvp2.programTypeId = 2;
		uvp2.city = "singapore";
		uvp2.country = "singapore";
		uvp2.dateYYYYMM = 200511;
		uvp2.teacher = "Tina";
		
		List<UnverifiedProgramProp> props = new ArrayList<>();
		props.add(uvp1);
		props.add(uvp2);
		
		Gson gson = new Gson();
		String json = gson.toJson(props);
		
		List<UnverifiedProgramProp> propsFromJson = 
			UnverifiedProgram.getUnverifiedProgramPropsFromJson(json);
		assertEquals(2, propsFromJson.size());
		assertEquals(1, propsFromJson.get(0).programTypeId);
		assertEquals("chennai", propsFromJson.get(0).city);
		assertEquals("india", propsFromJson.get(0).country);
		assertEquals(0, propsFromJson.get(0).dateYYYYMM);
		assertEquals(null, propsFromJson.get(0).teacher);
		
		assertEquals(2, propsFromJson.get(1).programTypeId);
		assertEquals("singapore", propsFromJson.get(1).city);
		assertEquals("singapore", propsFromJson.get(1).country);
		assertEquals(200511, propsFromJson.get(1).dateYYYYMM);		
		assertEquals("Tina", propsFromJson.get(1).teacher);
	}
	
//	@Test public void saveUnverifiedProgramsTest() {
//		//create members
//		ContactDetailProp c = new ContactDetailProp(); 
//		c.email = "thulasidhar@gmail.com";
//		thulasi = Member.create("isha", sgp.groupId, c, User.SUPER_USER);
//		assertEquals(1, thulasi.memberId);
//		Member.addOrDeleteProgram("isha", thulasi.memberId, mysticEye201401.programId, true, 
//				User.SUPER_USER);
//		
//		List<UnverifiedProgramProp> props = new ArrayList<>();
//		UnverifiedProgramProp prop = new UnverifiedProgramProp();
//		prop.programTypeId = shambhavi2Day.programTypeId;
//		prop.city = "Bangalore";
//		prop.country = "India";
//		prop.dateYYYYMM = 200901;		
//		props.add(prop);
//		
//		Member.saveUnverifiedPrograms(client, thulasi.memberId, props, User.SUPER_USER);
//		
//		thulasi = Member.safeGet(client, thulasi.memberId, User.SUPER_USER).toProp();
//		assertEquals(1,thulasi.programIds.size());
//		assertTrue(thulasi.programIds.contains(mysticEye201401.programId));
//		assertEquals(2,thulasi.programTypeIds.size());
//		assertTrue(thulasi.programTypeIds.contains(mysticEye1Day.programTypeId));
//		assertTrue(thulasi.programTypeIds.contains(shambhavi2Day.programTypeId));	
//	}
}
